package com.mdd.front.controller;

import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import com.mdd.front.service.IMansionService;
import com.mdd.front.validate.commons.PageValidate;
import com.mdd.front.validate.order.MansionSearchValidate;
import com.mdd.front.vo.order.MansionVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 大厦管理
 * @author shenjian
 * @createTime 2023年02月05日 23:20:00
 */
@RestController
@RequestMapping("api/mansion")
public class MansionController {


    @Resource
    IMansionService iMansionService;

    /**
     * 大厦列表
     *
     * @author shenjian
     * @param searchValidate 搜索参数
     * @return AjaxResult<PageResult<MansionVo>>
     */
    @GetMapping("/list")
    public AjaxResult<?> list(@Validated MansionSearchValidate searchValidate) {
        List<MansionVo> list = iMansionService.list(searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    public AjaxResult<MansionVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        return AjaxResult.success(iMansionService.detail(id));
    }
}
